/**
 * 初始化路由
 */
const requireDirectory = require('require-directory')
// 获取当前目录
const currentDir = process.cwd()
const path = `${currentDir}/routes`

class Init {
  static init (app) {
    requireDirectory(module, path, {
      visit: visitor
    })
    function visitor (obj) {
      app.use(obj.routes(), obj.allowedMethods())
    }
  }
}

module.exports = {
  Init
}